// import { login, logout, getInfo } from '@/api/user'
import store from '../index.js'
import Vue from 'vue'



const state = {
	 current_address_info: {
		lng: '',
		lat: '',
		name: '',
		city: ''
	 },  
	 city_select:''
}

const mutations = {
  SET_CURRENT_LOC: (state, data) => {
	  Vue.set(state,'current_address_info',{
		lng: data.longitude,
		lat: data.latitude,
		name: data.name,
		city: data.regeocodeData.addressComponent.city
	})
	if(!store.getters.city_select) {
		Vue.set(state,'city_select',data.regeocodeData.addressComponent.city)
	}
  }
}

const actions = {
  // user login

  setCurrentLoc({ commit }, data){
	  commit('SET_CURRENT_LOC', data)
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

